package 进阶.File类.获取;

import java.io.File;
import java.io.IOException;

public abstract class demo01 {
    public static void main(String[] args) {
        /*File file = new File("d:/www/qqq/a.txt");
        String path = file.getPath();
        String absolutePath = file.getAbsolutePath();
        String name = file.getName();
        System.out.println(name);
        System.out.println(absolutePath);
        System.out.println(path);*/
        show2();

    }

    private static void show2() {
        //创建多级文件夹
        File f2 = new File("d:/qqq/qwe");
        boolean mkdirs = f2.mkdirs();
        System.out.println(mkdirs);
        File f = new File("d:/qqq/qwe/1.txt");
        boolean newFile = false;
        try {
            newFile = f.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println(newFile);
        //等待十秒后删除这个文件
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        File f1 = new File("d:/qqq/qwe/1.txt");
        boolean delete = f1.delete();
        System.out.println(delete);
        File f3 = new File("d:/qqq");
        boolean b = f3.delete();
        System.out.println(b);
    }

    private static void show1() {
        //创建一个新文件
        File f = new File("d:/1.txt");
        boolean newFile = false;
        try {
            newFile = f.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println(newFile);
        //等待十秒后删除这个文件
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        File f1 = new File("d:/1.txt");
        boolean delete = f1.delete();
        System.out.println(delete);
    }

    private static void show() {
        File f = new File("D:\\pics\\wallpaper\\310795.jpg");
        System.out.println(f.length());
    }
}
